package com.lemner.motion.activity;

import android.content.Intent;
import android.content.SharedPreferences;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.lemner.motion.R;
import com.lemner.motion.base.BaseActivity;
import com.lemner.motion.bean.GetschoolBean;
import com.lemner.motion.util.FullScreen;


import java.util.ArrayList;
import java.util.List;


public class Register1Activity extends BaseActivity {
    private Button reg1_btn_done;
    private EditText reg1_et_stunum;
    private ImageView reg1_ib_back;
    private TextView reg1_tv_shcool;
   private String stunum , school;
    @Override
    public int getLayoutFile() {
        return R.layout.activity_register1;
    }

    @Override
    public void initView() {
        FullScreen.fullScreen(this,0x33131313);
        reg1_btn_done=(Button)findViewById(R.id.reg1_btn_done);
        reg1_et_stunum=(EditText)findViewById(R.id.reg1_et_stunum);
        reg1_ib_back=(ImageView)findViewById(R.id.reg1_ib_back);
        reg1_tv_shcool=(TextView)findViewById(R.id.reg1_tv_shcool);

    }

    @Override
    public void initEvent() {
        reg1_btn_done.setOnClickListener(this);
        reg1_tv_shcool.setOnClickListener(this);
        reg1_ib_back.setOnClickListener(this);
    }

    @Override
    public void initData() {
        school=getIntent().getStringExtra("schoolname");
        stunum=getIntent().getStringExtra("stunum");
        if(school!=null)
            reg1_tv_shcool.setText(school);
        if(!TextUtils.isEmpty(stunum))
            reg1_et_stunum.setText(stunum);
    }

    @Override
    public void onClick(View v) {
        stunum=reg1_et_stunum.getText().toString();
        switch (v.getId()){
            case R.id.reg1_tv_shcool:
                Intent intent=new Intent(Register1Activity.this,GetSchoolActivity.class);
                intent.putExtra("stunum",stunum);
                startActivity(intent);
                finish();
                   break;
            case R.id.reg1_btn_done:
                String school=reg1_tv_shcool.getText().toString();
                 if(TextUtils.isEmpty(school)){
                    showToast("学校为空,请选择注册学校");
                       return;
                }
                 else  if(TextUtils.isEmpty(stunum)) {
                    showToast("学号为空");
                     return;
                 }
                else {
                     Intent intent1=new Intent(Register1Activity.this, Register2Activity.class);
                     intent1.putExtra("schname",school);
                     intent1.putExtra("stunum",stunum);
                     startActivity(intent1);
                }
                break;
            case R.id.reg1_ib_back:
                startActivity(new Intent(Register1Activity.this,IndexActivity.class));
                finish();
                break;
            default:
                break;
        }

    }





}
